<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class APIGenerator {
	
	public static function generateKey($len = 12, $add = null) {
		$type = array(1,1,1);
		
	    $rand = ($type[0] == '1'  ? 'abcdefghijklmnpqrstuvwxyz' : '') .
	            ($type[1] == '1'  ? 'ABCDEFGHIJKLMNPQRSTUVWXYZ' : '') .
	            ($type[2] == '1'  ? '1234567890'                 : '') .
	            (strlen($add) > 0 ? $add                        : '');
	    if(!empty($rand)) 
		$rand = sha1( uniqid(mt_rand(), true) . uniqid( uniqid(mt_rand(), true), true) . time() );
	
	    return substr(str_shuffle( str_repeat($rand, 2) ), 0, $len);
	}
	
	
}